﻿namespace ChessToys
{
    using System;
    
    /// <summary>
    /// An abstract implementation of <see cref="IPiece"/> providing basic functionality.
    /// </summary>
    public abstract class AbstractPiece : IPiece
    {
        private Color _color;

        /// <summary>
        /// Initializes a new instance of the <see cref="AbstractPiece"/> class.
        /// </summary>
        /// <param name="color">The color of the piece.</param>
        protected AbstractPiece(Color color)
        {
            _color = color;
        }

        /// <summary>
        /// The color of the piece.
        /// </summary>
        public Color Color
        {
            get { return _color; }
        }

        /// <inheritdoc />
        public override string ToString()
        {
            return String.Format("{0} {1}", Color, Name);
        }

        /// <inheritdoc />
        public abstract String Name
        {
            get;
        }

        /// <inheritdoc />
        public String Sign
        {
            get
            {
                String sign = SpecificSign;
                if (Color == ChessToys.Color.White)
                {
                    return sign.ToUpper();
                }
                else
                {
                    return sign.ToLower();
                }
            }
        }

        protected abstract String SpecificSign
        {
            get;
        }
    }
}
